package com.example.floristshop.utils;

import com.example.floristshop.database.Flower;
import com.example.floristshop.database.Record;
import com.example.floristshop.database.User;

import org.litepal.LitePal;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;

public class DBFindUtil {
    public static User findUserByUserId(long id){
        List<User> list = LitePal.where("user_id==?", id+"").find(User.class);
        if(list.size()>0){
            return list.get(0);
        }else {
            return (new User());
        }
    }

    public static Flower findFlowerByFlowerId(long id){
        List<Flower> list = LitePal.where("flower_id==?", id+"").find(Flower.class);
        if(list.size()>0){
            return list.get(0);
        }else {
            return (new Flower());
        }
    }

    public static Record findRecordByTimestamp(long timestamp){
        List<Record> list = LitePal.where("timestamp==?", timestamp+"").find(Record.class);
        if(list.size()>0){
            return list.get(0);
        }else {
            return (new Record());
        }
    }
}
